Ext.define('DragonApp.view.monster.Query', {
    extend: 'Ext.form.Panel',

    requires: [
        'DragonApp.view.pub.form.field.CharacterID',
        'DragonApp.view.pub.combobox.Server'
    ],

    alias: ['widget.monsterquery'],

    controller: 'monster',
    reference: 'monsterform',

    title: '查询表单',

    bodyPadding: 5,
    border: false,


    fieldDefaults: {
        labelWidth: 60,
        labelAlign: 'right'
    },

    items: [{
        xtype: 'fieldcontainer',
        layout: 'hbox',
        defaults: {
            listeners: {
                specialKey: 'onTextFieldSpecialKey'
            }
        },
        items: [
            { xtype: "servercombobox", name: "sid", fieldLabel: "服务器", width: 238 },
            { xtype: "textfield_cid", name: "id", fieldLabel: "玩家ID", width: 238 },
            { xtype: "textfield", name: "nickname", fieldLabel: "玩家名", width: 238 }
        ]
    }],
    buttons: [{
        text: '取消',
        handler: function() {

            //清空查询表单
            var form = this.up('form').getForm();
            form.reset();

            //清空内容
            var panel = Ext.ComponentQuery.query('monsterpanel')[0];
            var grid = panel.down('grid');

            grid.queryById('filter-items').removeAll();

            //复位筛选条件
            var filter = grid.queryById('conditions');
            var box = filter && filter.getBoxes()[0];
            box && box.setValue(true);

            //搜索字段复位
            var searchField = panel.queryById('search_field');
            searchField.reset();

            //数据仓库复位
            var store = grid.getStore();
            store.removeAll();
        }
    }, {
        text: '查询',
        formBind: true,
        disabled: true,
        handler: 'onSubmitClick'
    }]
});